crypto = require('crypto');

function calcSignature(params, secret) {
    var arr = new Array();
    for(var key in params){
        arr.push(key + "=" + params[key]);
    }
    arr.sort();
    var data = arr.join("&");
    var base64Str = Buffer.from(data).toString('base64');

    const hmac = crypto.createHmac('sha1', secret);
    hmac.update(base64Str);
    return hmac.digest('hex').toUpperCase();
}
